﻿using System;
using System.Data;
using System.Text;
using System.Data.OleDb;
using DBUtility;
using System.Collections.Generic;

namespace DAL
{
    public class Infos
    {
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public List<ModelInfos> GetModelList()
        {
            List<ModelInfos> list = new List<ModelInfos>();
            DataSet ds = DbHelperOleDb.Query("select * from infos");
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                list.Add(DataRowToModel(ds.Tables[0].Rows[i]));
            }

            return list;
        }



        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ModelInfos DataRowToModel(DataRow row)
        {
            ModelInfos model = new ModelInfos();
            if (row != null)
            {
                if (row["aid"] != null && row["aid"].ToString() != "")
                {
                    model.AID = int.Parse(row["aid"].ToString());
                }
                if (row["burl"] != null)
                {
                    model.BUrl = row["burl"].ToString();
                }
                if (row["bname"] != null)
                {
                    model.BName = row["bname"].ToString();
                }
            }
            return model;
        }
    }

    public class ModelInfos
    {
        public int AID { get; set; }
        public string BName { get; set; }
        public string BUrl { get; set; }
    }
}
